#ifndef __MESSAGE_HPP__
#define __MESSAGE_HPP__

#include "../core.hpp"
#include <string>
class Message {
public: 
    winux::Mixed data;

    enum MessageType {
        Unkonw = 0,
        CMLoginGuest,
        CMLogout,
        CMUserIn,
        CMUserOut,
        CMAddBubble,

        MCWelcome,
        MCLoginGuest,//登陆响应
        MCLogout,
        MCUserIn,   //广播用户进入
        MCRoomInfo, //发送房间INFO
        MCUserOut,  //广播用户退出
        MCAddBubble,//发言响应
        MCArriveBubble, //广播发言
        MCError,//错误
    };
    MessageType type = Unkonw;
    void json( std::string const& str ) {
        data.json( str );
    }
    std::string json( ) {
        return data.json();
    }

    Message( std::string const& str ) {
        json( str );
        type = static_cast<MessageType>( static_cast<int>(data["type"]) );
    }

    Message( MessageType type )
        : type ( type )
    {
        data.createCollection();
        data["type"] = type;
    }
};

#endif //__MESSAGE_HPP__